﻿using System;
using HiTeachers.Data.Manager;
using HiTeachers.Entities;
using HiTeachers.Interfaces;
using HiTeachers.Utilities;
using NHibernate;

namespace HiTeachers.Data
{
    public class FeeConfigDao : AbstractNHibernateDao<FeeConfig, Guid>, IFeeConfigDao
    {
        public FeeConfig GetByPeriod(int period)
        {
            try
            {
                const string hsql = "from FeeConfig fc where fc.Period = :period";

                IQuery query = NHibernateSession.CreateQuery(hsql);
                query.SetInt32("period", period);

                return query.UniqueResult<FeeConfig>();
            }
            catch (Exception ex)
            {
                Logger.Debug(ex.Message);
                return null;
            }

        }
    }
}
